#ifndef __OCFEXTDB_H__
#define __OCFEXTDB_H__


#include "OcfExtDBImpl.h"


////////////////////////////////////////////////////////////////////////////////
//
class COcfExtDB: public COcfExtImpl
{
public:
	COcfExtDB(IUnknown *pIUnkOuter, CDllServer *pcDllServer, COcfExtImplBase* pcBase);
	virtual ~COcfExtDB();

public:
	virtual HRESULT __stdcall fnInit(USHORT uiServerID, ULONG ulMaxBindX, BYTE byServiceType, IUnknown* pISink);
	virtual HRESULT __stdcall fnUninit();
	virtual HRESULT __stdcall fnSetConfigPath(unsigned char* pszCfgPath);
	virtual HRESULT __stdcall fnGetStatus(LONG* plStatus);
	virtual HRESULT __stdcall fnBind(ULONG ulBindX, ULONG ulIdentity, ULONG ulKey);
	virtual HRESULT __stdcall fnUnbind(ULONG ulBindX, ULONG ulIdentity, ULONG ulKey);
	virtual HRESULT __stdcall fnIn(ULONG ulBindX, ULONG ulIdentity, LONG lLen, unsigned char* pchData);
	virtual HRESULT __stdcall fnRequestAnything(LONG lLenQuery, unsigned char* pchQuery, ULONG ulMaxLenRet, LONG* plLenRet, unsigned char* pchRet);

public:
	virtual HRESULT __stdcall QueryInterfaceEx(REFIID iid, void** ppv);

public:
	void Logging(const char* pszFormat, ...);

private:
	COcfDBWorkList m_OcfDBList;

	char m_szODBCConnString[DF_MAX_DB_COUNT][SAFE_CONNSTR_LEN];

	int m_nODBCConnCount;
	int m_nODBCWaitTime;
	int m_nODBCMaxCount;
};

extern COcfExtDB* GetOcfExtDBInstance();

////////////////////////////////////////////////////////////////////////////////
//
class COcfExtDBMainControlCenter: public CMainControlCenter
{
public:
	COcfExtDBMainControlCenter(CLSID& clsidComponent, char* pszFriendlyName, char* pszVerIndProgID, char* pszProgID):CMainControlCenter(clsidComponent, pszFriendlyName, pszVerIndProgID, pszProgID) {}
	virtual ~COcfExtDBMainControlCenter() {}

public:
	virtual COcfExtImpl* CreateComponent(IUnknown *pIUnkOuter, CDllServer *pcDllServer, COcfExtImplBase* pcBase)
	{
		return new COcfExtDB(pIUnkOuter, pcDllServer, pcBase);
	}
};

#endif
